package utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import common.Constant;
import common.MyApplication;

/**
 * Created by Administrator on 2017/3/21.
 * 乱七八糟的工具
 */

public class VariousUtils {
    //去掉https用的
    public static String noHttps(String value){
        String newValue = value ;
        if(value.contains("https")){
            String[] httpses = value.split("https");
            String httpse = httpses[1];
            newValue = "http"+ httpse;
        }
        return newValue;
    }

    //判断当前id和传入id是否相同,用于评论
    public static boolean isSamId(String id){
        if(SPUtils.getSharedPreferences().getString(Constant.USER_ID,"").equals(id)){
            return true;
        }
        return false;
    }

    //获取应用版本号
    public static String getVersion() {
        try {
            PackageManager manager = MyApplication.getContext().getPackageManager();
            PackageInfo info = manager.getPackageInfo( MyApplication.getContext().getPackageName(), 0);
            String version = info.versionName;
            return version;
        } catch (Exception e) {
            e.printStackTrace();
            return "没有版本号";
        }
    }


}
